<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    {{template "header.html" .}}
</head>

<body>

<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">系统管理</a>
        <a href="">角色管理</a>
        <a>
          <cite>角色列表</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>

<div class="x-body">

    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so">
            <input class="layui-input" placeholder="开始日" name="start_time" id="start_time" value="{{.PageInfo.Where.start_time}}">
            <input class="layui-input" placeholder="截止日" name="end_time" id="end_time" value="{{.PageInfo.Where.end_time}}">
            <input type="text" name="role_name"  placeholder="请输入用户名" autocomplete="off" class="layui-input" value="{{.PageInfo.Where.role_name}}">
            <button class="layui-btn"  lay-submit="" lay-filter="sreach" style="margin-top: -3px;"><i class="layui-icon">&#xe615;</i></button>
        </form>
    </div>

    <xblock>

        <button class="layui-btn" onclick="x_admin_show('添加角色','{{urlfor "SysRoleController.FormSysRole"}}')"><i class="layui-icon"></i>添加</button>

        <button class="layui-btn" style="background-color: #5FB878" onclick="modifyStatusByBatch('{{urlfor "SysRoleController.ModifySysRoleStatus"}}',1)"><i class="layui-icon layui-icon-play"></i>批量开启</button>
        <button class="layui-btn layui-bg-orange" onclick="modifyStatusByBatch('{{urlfor "SysRoleController.ModifySysRoleStatus"}}',0)"><i class="layui-icon layui-icon-pause"></i>批量关闭</button>
        <button class="layui-btn layui-btn-danger" onclick="deleteDataByBatch('{{urlfor "SysRoleController.DeleteSysRole"}}')"><i class="layui-icon layui-icon-delete"></i>批量删除</button>

        <span class="x-right" style="line-height:40px">共有数据：{{.PageInfo.TotalRows}} 条</span>
    </xblock>

    <table class="layui-table">
        <thead>
        <tr>
            <th>
                <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th>ID</th>
            <th>角色名</th>
            <th>简介</th>
            <th>创建时间</th>
            <th>更新时间</th>
            <th>角色状态</th>
            <th>操作</th>
        </thead>
        <tbody>

        {{range $key,$value := .RoleList}}
            <tr>
                <td>
                    <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='{{$value.Id}}'><i class="layui-icon">&#xe605;</i></div>
                </td>
                <td>{{$value.Id}}</td>
                <td>{{$value.RoleName}}</td>
                <td>{{$value.Intro}}</td>
                <td>
                    {{$value.CreateTime | convertt}}
                </td>
                <td>
                    {{$value.UpdateTime| convertt}}
                </td>
                <td>
                    {{if eq $value.RoleStatus 1}}
                        <span class="layui-badge" style="background-color: #5FB878" >开启</span>
                    {{else}}
                        <span class="layui-badge layui-bg-orange">关闭</span>
                    {{end}}
                </td>
                <td class="td-manage">

                    {{if eq $value.RoleStatus 1}}
                        <a onclick="modifyStatusByOne('{{urlfor "SysRoleController.ModifySysRoleStatus"}}',this,'{{$value.Id}}','0')" href="javascript:;"  title="关闭">
                            <i class="layui-icon layui-icon-pause"></i>
                        </a>
                    {{else}}
                        <a onclick="modifyStatusByOne('{{urlfor "SysRoleController.ModifySysRoleStatus"}}',this,'{{$value.Id}}','1')" href="javascript:;"  title="启用">
                            <i class="layui-icon layui-icon-play"></i>
                        </a>
                    {{end}}

                    <a title="编辑"  onclick="x_admin_show('编辑角色','{{urlfor "SysRoleController.FormSysRole" "role_id" $value.Id}}')" href="javascript:;">
                        <i class="layui-icon">&#xe642;</i>
                    </a>
                    <a title="删除" onclick="deleteDataByOne('{{urlfor "SysRoleController.DeleteSysRole"}}',this,'{{$value.Id}}')" href="javascript:;">
                        <i class="layui-icon">&#xe640;</i>
                    </a>
                </td>
            </tr>
        {{end}}
        </tbody>
    </table>

    <div id="pageDiv"></div>

</div>
<script>
    //分页
    layui.use('laypage', function () {
        var laypage = layui.laypage;
        //执行一个laypage实例
        laypage.render({
            elem: 'pageDiv' //注意，这里的 test1 是 ID，不用加 # 号
            , count: "{{.PageInfo.TotalRows}}" //数据总数，从服务端得到
            , limit: "{{.PageInfo.RowsNum}}" //每页显示的条数
            , curr:  "{{.PageInfo.PageNum}}"
            , theme: "#c00"
            , layout: ['count', 'prev', 'page', 'next', 'skip']
            , jump: function (obj, first) {
                //首次不执行
                if (!first) {
                    window.location.href = "{{.PageInfo.PageUrl}}page_num=" + obj.curr
                }
            }
        });
    });
</script>

</body>

</html>